<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="GRID_PAGE_SIZE" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_FIELD_VALUES_COLLECTION_KEY" />
<atleap:globalProperty name="${pageScope.GRID_PAGE_SIZE}" defaultValue="10" type="integer" var="pageSize" />
<c:set var="multipleDisabled" value="false" />

<atleap:isUserInRole roles="core-contentFieldValue-createOrUpdate" var="canCreateOrUpdate" />
<atleap:isUserInRole roles="core-contentFieldValue-view" var="canView" />
<atleap:isUserInRole roles="core-contentFieldValue-delete" var="canDelete" />

<c:set var="infoCells" value="3" />
<c:set var="constantButtonCells" value="0" />
<c:set var="additionalCells" value="0" />
<c:if test="${canCreateOrUpdate}">
	<c:set var="additionalCells" value="${additionalCells+1}" />
</c:if>
<c:if test="${canView}">
	<c:set var="additionalCells" value="${additionalCells+1}" />
</c:if>
<c:if test="${canDelete}">
	<c:set var="additionalCells" value="${additionalCells+1}" />
</c:if>

<atleap:content identifier="cfvListInfo" ignore="true" />
<atleap:grid name="contentFieldValuesGrid" pageSize="${pageSize}">
	<atleap:messages />
	<atleap:message key="core.contentFieldValue.errors.nothingChecked" var="errorMessage" />
    <atleap:queryParameter name="contentFieldId" value="${requestScope.contentFieldId}" />
    <atleap:form action="core/contentFieldValue/processValueSet" method="POST" onsubmit="return hasCheckedBox(this, 'toggleAll', &#039;${errorMessage}&#039;)">
		<table border="0" cellpadding="0" cellspacing="0" class="grid">
			<thead>
				<tr nowrap="nowrap">
					<th width="20" align="center" class="checkbox">
        			    <input type="checkbox" id="toggleAll" onclick="toggleAllCheckBoxes(this.form, this.id, null);" />
                    </th>
					<th nowrap="nowrap">
						<atleap:message key="core.contentFieldValue.form.language" />
					</th>
					<th nowrap="nowrap">
						<atleap:message key="core.contentFieldValue.form.lastUpdatedDatetime" />
					</th>
                    <c:if test="${constantButtonCells + additionalCells > 0}">
                        <th colspan="${constantButtonCells + additionalCells}">
                            <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/spacer.gif" />" border="0"  />
                        </th>
                    </c:if>
				 </tr>
			</thead>
			<tbody>
                <atleap:contextMenu var="menuId">
                    <atleap:rowsIterator collection="${requestScope[pageScope.CONTENT_FIELD_VALUES_COLLECTION_KEY]}"  var="entry" oddClass="oddRow" evenClass="evenRow">
                        <atleap:itemSet>
                            <c:set var="contentLocale" value="${entry.key}" />
                            <c:set var="contentFieldValue" value="${entry.value}" />
                            <atleap:rewriteUrl action="core/contentFieldValue/view?contentFieldId=${requestScope.contentFieldId}" var="defaultUrl">
                                <atleap:param name="locale" value="${contentLocale.identifier}" />
                            </atleap:rewriteUrl>
                            <c:set var="onTrClickCode" value="" />
                            <c:set var="tdClass" value="defaultCursorCell" />
                            <c:if test="${contentFieldValue != null && canView}">
                                <c:set var="onTrClickCode" value="dispatchGridTrClick(event, this, &#039;${defaultUrl}&#039;);" />
                                <c:set var="tdClass" value="pointerCursorCell" />
                            </c:if>
                            <tr class="${rowClass}" oncontextmenu="return showContextMenu(${menuId}, event, ${indexId});" onclick="${onTrClickCode}">
                                <td align="center" class="defaultCursorCell"><html:checkbox property="checkedBox(${contentLocale.identifier})" /></td>
                                <td class="${tdClass}">
                                    <atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
                                    <c:if test="${empty languageTitle}">
                                        <c:set var="languageTitle" value="${contentLocale.identifier}" />
                                    </c:if>
                                    ${languageTitle}
                                </td>
                                <td class="${tdClass}">
                                    <c:if test="${contentFieldValue != null}">
                                        <atleap:formatDate value="${contentFieldValue.lastUpdatedDatetime}" type="datetime" />
                                    </c:if>
                                </td>
                                <atleap:item includeInContextMenu="${canCreateOrUpdate}" includeInPage="${canCreateOrUpdate}">
                                    <td align="center" width="20" height="20" valign="middle" class="defaultCursorCell">
                                        <atleap:message key="core.commons.buttons.callCreateOrUpdate" var="callCreateOrUpdateMsg" />
                                        <atleap:itemEnabled>
                                            <atleap:itemLink action="core/contentFieldValue/callCreateOrUpdate?contentFieldId=${requestScope.contentFieldId}" title="${callCreateOrUpdateMsg}">
                                                <atleap:param name="locale" value="${contentLocale.identifier}" />

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/edit.gif" />" border="0" title="${callCreateOrUpdateMsg}" alt="${callCreateOrUpdateMsg}" align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${callCreateOrUpdateMsg}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemEnabled>
                                    </td>
                                </atleap:item>
                                <atleap:item enabled="${contentFieldValue != null}" includeInContextMenu="${canView}" includeInPage="${canView}">
                                    <atleap:message key="core.commons.buttons.view" var="viewMsg"/>
                                    <td align="center" width="20" height="20" valign="middle" class="defaultCursorCell">
                                        <atleap:itemEnabled>
                                            <atleap:itemLink action="core/contentFieldValue/view?contentFieldId=${requestScope.contentFieldId}" title="${viewMsg}">
                                                <atleap:param name="locale" value="${contentLocale.identifier}" />

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/view.gif" />" border="0" title="${viewMsg}" alt="${viewMsg}" align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${viewMsg}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemEnabled>
                                        <atleap:itemDisabled>
                                            <atleap:message key="core.contentFieldValue.form.viewDisabled" var="viewDisabledMsg" />
                                            <atleap:itemLink title="${viewDisabledMsg}">

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/viewDisabled.gif" />" border="0" alt="${viewDisabledMsg}" title="${viewDisabledMsg}"  align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${viewMsg}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemDisabled>
                                    </td>
                                </atleap:item>
                                <atleap:item enabled="${contentFieldValue != null}" includeInContextMenu="${canDelete}" includeInPage="${canDelete}">
                                    <atleap:message key="core.commons.buttons.delete" var="deleteTitle"/>
                                    <td align="center" width="20" height="20" valign="middle" class="defaultCursorCell">
                                        <atleap:itemEnabled>
                                            <atleap:itemLink action="core/contentFieldValue/delete?contentFieldId=${requestScope.contentFieldId}" transaction="true" confirmExpression="confirmDelete();" title="${deleteTitle}">
                                                <atleap:param name="locale" value="${contentLocale.identifier}" />

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/delete.gif" />" border="0" title="${deleteTitle}" alt="${deleteTitle}" align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${deleteTitle}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemEnabled>
                                        <atleap:itemDisabled>
                                            <atleap:message key="core.contentFieldValue.form.deleteDisabled" var="deleteDisabledMsg" />
                                            <atleap:itemLink title="${deleteDisabledMsg}">

                                                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/deleteDisabled.gif" />" border="0" alt="${deleteDisabledMsg}" title="${deleteDisabledMsg}"  align="absmiddle" />
                                                        <atleap:itemLabel>
                                                            ${deleteTitle}
                                                        </atleap:itemLabel>
                                            </atleap:itemLink>
                                        </atleap:itemDisabled>
                                    </td>
                                </atleap:item>
                            </tr>
                        </atleap:itemSet>
                    </atleap:rowsIterator>
                </atleap:contextMenu>
                <atleap:noRows>
                    <c:set var="multipleDisabled" value="true" />
				    <tr>
						<td class="tfoot" colspan="${infoCells + constantButtonCells + additionalCells}" align="center">
							<em><atleap:message key="core.commons.nothingToShow"/></em>
						</td>
                    </tr>
			    </atleap:noRows>
			</tbody>
			<tfoot>
				<tr>
					<td></td>
					<td colspan="2" align="left">
						<table width="100%" class="gridSubFooter" cellpadding="0" cellspacing="0">
							<tr>
								<td>
									<atleap:message key="core.commons.selected" />
									<html:hidden property="contentFieldId" value="${requestScope.contentFieldId}" />
								</td>
                                <c:if test="${canCreateOrUpdate}">
                                    <td>
                                        <atleap:submit property="editSelected" styleClass="button" style="margin: 5px 10px 5px 0px; width: 180px;" disabled="${multipleDisabled}">
                                            <atleap:message key="core.commons.buttons.callCreateOrUpdate" />
                                        </atleap:submit>
                                    </td>
                                </c:if>
                                <c:if test="${canView}">
                                    <td>
                                        <atleap:submit property="viewSelected" styleClass="button" style="margin: 5px 10px 5px 0px" disabled="${multipleDisabled}">
                                            <atleap:message key="core.commons.buttons.view" />
                                        </atleap:submit>
                                    </td>
                                </c:if>
                                <c:if test="${canDelete}">
                                    <td align="left">
                                        <atleap:submit property="deleteSelected" styleClass="button" style="margin: 5px 5px 5px 0px" disabled="${multipleDisabled}">
                                            <atleap:message key="core.commons.buttons.delete" />
                                        </atleap:submit>
                                    </td>
                                </c:if>
							</tr>
						</table>
					</td>
                    <c:if test="${constantButtonCells + additionalCells > 0}">
					    <td colspan="${constantButtonCells + additionalCells}"></td>
                    </c:if>
				</tr>
			</tfoot>
		</table>
    </atleap:form>
</atleap:grid>
<br />
